package com.milepost.workflow.flowinstform.ctrl;

import com.milepost.workflow.flowinstform.entity.FlowInstFormEntity;
import com.milepost.workflow.flowinstform.service.FlowInstFormService;
import com.milepost.workflow.response.Response;
import com.milepost.workflow.response.ResponseHelper;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huarf
 * @Description
 * @create 2022-03-26 15:05
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/flowInstForm")
public class FlowInstFormCtrl {

    private final FlowInstFormService flowInstFormService;


    /**
     * 查看流程表单
     * @param flowInstId
     * @return
     */
    @GetMapping("/getById")
    public Response<FlowInstFormEntity> getById(String flowInstId) {

        Response<FlowInstFormEntity> response = null;

        try {
            FlowInstFormEntity flowInstFormEntity = flowInstFormService.getByFlowInstId(flowInstId);
            response = ResponseHelper.createSuccessResponse(flowInstFormEntity);
        } catch (Exception e) {
            log.error("查看流程表单异常", e);
            response = ResponseHelper.createExceptionResponse(e);
        }

        return response;
    }

}
